#!/usr/bin/node

const log = console.log,
      http = require('http');

http.createServer((req,res)=>{
  //status code
  //header txt/html
  if(req.url !== '/'){
    res.statusCode = 404 ;
    res.setHeader('Content-Type', 'text/html');
    res.end('<h1>Not Found</h1>');
    return;
  }
  //把请求体的数据拿出来
  req.pipe(process.stdout);

  res.end('ok');
}).listen(8080);

log('hello world');
